package com.easydev.basic.web.listener;

import javax.servlet.ServletContextEvent;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.ContextLoaderListener;

/**
 * listener有多种实现，本案例以继承ContextLoaderListener为例，用来在应用启动时做一些处理
 * 
 * @author glf
 * @version 1.0
 * @CreateDate 2016年3月17日
 */
public class DemoListerner extends ContextLoaderListener {

    private Logger log = LoggerFactory.getLogger(DemoListerner.class);

    /**
     * 该方法会在spring容器初始化之前被调用
     * 
     * @author glf
     * @param event
     */
    @Override
    public void contextInitialized(ServletContextEvent event) {
        log.info("DemoListerner contextInitialized执行");
        super.contextInitialized(event);
    }

    /**
     * 该方法会在spring容器销毁前被调用
     * 
     * @author glf
     * @param event
     */
    @Override
    public void contextDestroyed(ServletContextEvent event) {
        log.info("DemoListerner contextDestroyed执行");
        super.contextDestroyed(event);
    }

}
